<script setup>
import { ref } from "vue";

// eslint-disable-next-line no-undef
defineProps({
  counter: {
    type: Number,
    // 默认值
    default: 0,
  },
});
const num = ref(100);
let btnClick = (counter) => {
  console.log("two组件被点击");
  num.value = 200;
  // 如果传入的有counter 让num等于counter
  if (counter) num.value = counter;
};
// eslint-disable-next-line no-undef
defineExpose({
  btnClick,
});
</script>

<template>
  <div class="two">
    <h2>{{ num }}</h2>
    <h2>{{ counter }}</h2>
  </div>
</template>

<style scoped>
.two {
}
</style>